package com.ktjy.proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class IntermediaryMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {

       insertLog1();
        Object feedback = methodProxy.invokeSuper(o, objects);
        closeLog();
        return "返回信息：" + feedback;
    }

    @Deprecated
    public void insertLog1() {
        System.out.println("准备工作:插入日志");
    }

    public void closeLog() {
        System.out.println("结束工作：关闭日志文件");
    }
}
